branch-4.1:[fix](fe) Fix redundant aggregation in agg-union query plan #62231#63577
Merged
Conversation
…2231) When multiple grouped queries are combined via UNION ALL on randomly distributed tables without PhysicalDistribute operators, Doris was generating redundant local aggregation and global aggregation layers without a distribute operator between them. The issue was in the `banAggUnionAll` method in ChildrenPropertiesRegulator, which was too aggressively forbidding one-phase aggregation for all agg-union patterns, regardless of whether the union inputs had PhysicalDistribute operators. Modified the `banAggUnionAll` method to only forbid one-phase aggregation when the union inputs actually have PhysicalDistribute operators: 1. Checks each group in the union 2. Examines all physical expressions in each group 3. Only forbids one-phase agg if any input has PhysicalDistribute 4. Allows one-phase agg if no inputs have PhysicalDistribute Added regression test `agg_union_group_by.groovy` to verify correct behavior Improved query optimization: Eliminated redundant aggregation layers in UNION ALL queries with GROUP BY on randomly distributed tables.
Contributor
Author
|
run buildall |
Contributor
FE Regression Coverage ReportIncrement line coverage |
yiguolei
approved these changes
May 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
picked from #62231